package cn.seocoo.platform.web.controller.base;

import java.util.List;

import cn.seocoo.platform.common.constant.ClassContants;
import cn.seocoo.platform.framework.util.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.seocoo.platform.common.annotation.Log;
import cn.seocoo.platform.common.enums.BusinessType;
import cn.seocoo.platform.base.domain.BaseVehicleType;
import cn.seocoo.platform.base.service.IBaseVehicleTypeService;
import cn.seocoo.platform.common.core.controller.BaseController;
import cn.seocoo.platform.common.core.page.TableDataInfo;
import cn.seocoo.platform.common.core.domain.AjaxResult;
import cn.seocoo.platform.common.utils.poi.ExcelUtil;

/**
 * 车型 信息操作处理
 * 
 * @author wujian
 * @date 2019-12-18
 */
@Controller
@RequestMapping("/base/baseVehicleType")
public class BaseVehicleTypeController extends BaseController
{
    private String prefix = "base/baseVehicleType";
	
	@Autowired
	private IBaseVehicleTypeService baseVehicleTypeService;
	
	@RequiresPermissions("base:baseVehicleType:view")
	@GetMapping()
	public String baseVehicleType()
	{
	    return prefix + "/baseVehicleType";
	}
	
	/**
	 * 查询车型列表
	 */
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(BaseVehicleType baseVehicleType)
	{
		baseVehicleType.setDelFlag(ClassContants.NO_DEL_FLAG);
		startPage();
        List<BaseVehicleType> list = baseVehicleTypeService.selectBaseVehicleTypeList(baseVehicleType);
		return getDataTable(list);
	}
	
	

	
	/**
	 * 新增车型
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存车型
	 */
	@Log(title = "车型", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(BaseVehicleType baseVehicleType)
	{
		baseVehicleType.setCreateBy(ShiroUtils.getSysUser().getUserName());
		baseVehicleType.setDelFlag(ClassContants.NO_DEL_FLAG);
		return toAjax(baseVehicleTypeService.insertBaseVehicleType(baseVehicleType));
	}

	/**
	 * 修改车型
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		BaseVehicleType baseVehicleType = baseVehicleTypeService.selectBaseVehicleTypeById(id);
		mmap.put("baseVehicleType", baseVehicleType);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存车型
	 */
	@Log(title = "车型", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(BaseVehicleType baseVehicleType)
	{		
		return toAjax(baseVehicleTypeService.updateBaseVehicleType(baseVehicleType));
	}



	/**
	 * 类别列表
	 */
	@GetMapping("/detail/{id}")
	public String detail(@PathVariable("id") Integer id, ModelMap mmap) {

		mmap.put("vehicleId", id);
		return  "base/baseCategory/baseCategory";
	}



















	
	/**
	 * 删除车型
	 */
	/*
	@Log(title = "车型", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{
		BaseVehicleType baseVehicleType = new BaseVehicleType();
		baseVehicleType.setDelFlag(ClassContants.IS_DEL_FLAG);
		baseVehicleType.setId(Integer.valueOf(ids));
		return toAjax(baseVehicleTypeService.updateBaseVehicleType(baseVehicleType));
	}*/





	
}
